package com.pureut.system.controller;

import java.util.*;

import com.pureut.common.core.web.controller.BaseController;
import com.pureut.common.core.web.domain.AjaxResult;
import com.pureut.common.security.utils.SecurityUtils;
import com.pureut.system.domain.SysBusinessRule;
import com.pureut.system.domain.vo.SysBusinessRuleVo;
import com.pureut.system.service.ISysBusinessRuleService;
import org.springframework.jdbc.object.UpdatableSqlQuery;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


/**
 * @Author: pureut
 * @Date: 2025-04-07 17:40:36
 * @Desc: 业务规则Controller
 */
@RestController
@RequestMapping("/system/sysBusinessRule")
public class SysBusinessRuleController extends BaseController{

    /**
     * 业务规则Service
     */
    @Resource
    private ISysBusinessRuleService sysBusinessRuleService;

    /**
     * 获取业务规则详细信息
     * @param: id 业务规则主键
     * @return: Json工具类对象
     */
    //    @SaCheckPermission("sysBusinessRule-query")
    @GetMapping(value = "/info")
    public AjaxResult getInfo() {
        return AjaxResult.success(sysBusinessRuleService.getById(1));
    }



    /**
     * 修改业务规则
     * @param: sysBusinessRule 业务规则对象
     * @return: Json工具类对象
     */
    @PutMapping
    public AjaxResult edit( @RequestBody SysBusinessRuleVo sysBusinessRuleVo) {
        boolean update = sysBusinessRuleService.lambdaUpdate().set(SysBusinessRule::getIsFlag1, sysBusinessRuleVo.getIsFlag1())
                .set(SysBusinessRule::getIsFlag2, sysBusinessRuleVo.getIsFlag2())
                .set(SysBusinessRule::getIsFlag3, sysBusinessRuleVo.getIsFlag3())
                .eq(SysBusinessRule::getId, 1).update();
        return toAjax(update);

    }
}
